#ifndef UDPCOMM_H
#define UDPCOMM_H

#endif // UDPCOMM_H

#include <QObject>
#include <QUdpSocket>
#include <QHostAddress>

class UdpComm: public QObject{
    Q_OBJECT
public:
    explicit UdpComm(quint16 localPort, QObject *parent = nullptr);
    ~UdpComm();

   // void sendData(const QByteArray &data,const QHostAddress &remoteAddr, quint16 remotePort);
signals:    //信号
    void dataReceived(const QByteArray &data, const QHostAddress &senderAddr, quint16 senderPort);
    void errorOccurred(const QString &error);

private slots:
    void onReadyRead();

private:
    QUdpSocket *udpSocket;
    quint16 port;
};
